(
	function()
	{
		var vendors  = new Array("ms", "moz", "webkit", "o");
		for (var i = vendors.length - 1; !window.requestAnimationFrame && i--;)
			window.requestAnimationFrame = window[vendors[i] + "RequestAnimationFrame"];
		for (i = vendors.length - 1; !window.cancelAnimationFrame && i--;)
			window.cancelAnimationFrame = window[vendors[i] + "CancelAnimationFrame"] || window[vendors[i] + "CancelRequestAnimationFrame"];
		if (!window.requestAnimationFrame)
		{
			var previousTime = 0;
			window.requestAnimationFrame = function(callback, element)
			{
				var currentTime = new Date().getTime();
				var timeToCall  = Math.max(0, 16 - (currentTime - previousTime));
				var id          = window.setTimeout(function() { callback(currentTime + timeToCall); }, timeToCall);
				previousTime    = currentTime + timeToCall;
				return id;
			}
		}
		if (!window.cancelAnimationFrame)
			window.cancelAnimationFrame = function(id)
			{
				clearTimeout(id);
			}
	}
)();

try
{

var canvas  = document.createElement("canvas");
var context = canvas.getContext("2d");

canvas.width  = 800;
canvas.height = 600;
document.body.appendChild(canvas);

var cache   = new Cache();
var scene   = new Scene();

scene.setNext(new SceneTitle());

function mainLoop()
{
	var ready = true;
	if (scene.getNext())
		ready = cache.isReady();
	if (ready)
	{
		scene.update();
		scene.draw(context);
	}
	setTimeout(mainLoop, 16);
}

mainLoop();

}
catch (error)
{
	alert(error.message);
}